﻿Imports TerrariaVB.Core.GameObjects

'
' Copyright (c) 2010-2012, MatthiWare
'
' Permission is hereby granted, free of charge, to any person obtaining a
' copy of this software and associated documentation files (the "Software"),
' to deal in the Software without restriction, including without limitation
' the rights to use, copy, modify, merge, publish, distribute, sublicense,
' and/or sell copies of the Software, and to permit persons to whom the
' Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in
' all copies or substantial portions of the Software. 
' You shall include 'MatthiWare' in the credits/about section of the program
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
' FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'

Public Class GameObjBase
    Inherits GameObject

    Public Function Contains(block As Block) As Boolean
        Return Me.Contains(block.X, block.Y)
    End Function

    Public Function Contains(x As Int32, y As Int32) As Boolean
        Return ((((Me.X <= x) And (x < (Me.X + Me.Width))) And (Me.Y <= y)) And (y < (Me.Y + Me.Height)))
    End Function

    Public Function Contains(pt As Point) As Boolean
        Return Me.Contains(pt.X, pt.Y)
    End Function

    Public Sub New(pt As Point, sz As Size)
        MyBase.New()
        Me.Location = pt
        Me.Size = sz
    End Sub

#Region "Properties"

    Private _x As Double
    Public Overridable Property X() As Double
        Get
            Return _x
        End Get
        Set(ByVal value As Double)
            _x = value
            _l = New Point(value, Y)
        End Set
    End Property

    Private _y As Double
    Public Overridable Property Y() As Double
        Get
            Return _y
        End Get
        Set(ByVal value As Double)
            _y = value
            _l = New Point(X, value)
        End Set
    End Property

    Private _w As Double
    Public Property Width() As Double
        Get
            Return _w
        End Get
        Set(ByVal value As Double)
            _w = value
            _s = New Size(value, Height)
        End Set
    End Property

    Private _h As Double
    Public Property Height() As Double
        Get
            Return _h
        End Get
        Set(ByVal value As Double)
            _h = value
            _s = New Size(Width, value)
        End Set
    End Property

    Private _l As Point
    Public Property Location() As Point
        Get
            Return _l
        End Get
        Set(ByVal value As Point)
            _l = value
            _x = value.X
            _y = value.Y
        End Set
    End Property

    Private _s As Size
    Public Property Size() As Size
        Get
            Return _s
        End Get
        Set(ByVal value As Size)
            _s = value
            _h = value.Height
            _w = value.Width
        End Set
    End Property

#End Region

End Class
